<template>
    <div class="con">
        <div class="nav">
            <p @click="getBank(1)" :class="{ active: isActive}">信用卡</p>
            <p @click="getBank(0)" :class="{ active: !isActive}">储蓄卡</p>
        </div>
        <div class="title">
            <p style="text-align: left;">银行名称</p>
            <p v-show="show">单笔限额(元)</p>
            <p v-show="show">单日限额(元)</p>
        </div>
        <div class="list" v-for="(item,index) in data" :key="index">
            <ul>
                <li style="text-align: left;">{{item.bankName}}</li>
                <li v-show="show">{{item.singleAmount}}</li>
                <li v-show="show">{{item.dayAmount}}</li>
            </ul>
        </div>
    </div>
</template>
   
<script>
export default {
    name: "banklist",
    data() {
        return {
            timestamp: "",
            data: {},
            cardType: 1,
            isActive: true,
            show: true
        };
    },
    methods: {
        getBank(type) {
            this.cardType = type;
            if (this.cardType == 1) {
                this.isActive = true;
                this.show = true;
            } else {
                this.isActive = false;
                this.show = false;
            }
            this.axios({
                method: "post",
                url: `${
                    this.siteUrl
                }/app/bankCard/getBank?appid=web.2019&format=json&timestamp=${
                    this.timestamp
                }`,
                data: {
                    cardType: this.cardType
                }
            })
                .then(response => {
                    if (response.data.success == 1) {
                        this.data = response.data.data;
                    } else {
                        this.$toast(response.data.message);
                    }
                })
                .catch(error => {
                    console.log(error);
                    this.$toast("连接服务器异常");
                });
        }
    },
    mounted() {
        this.timestamp = Date.parse(new Date()) + 100;

        this.axios({
            method: "post",
            url: `${
                this.siteUrl
            }/app/bankCard/getBank?appid=web.2019&format=json&timestamp=${
                this.timestamp
            }`,
            data: {
                cardType: this.cardType
            }
        })
            .then(response => {
                if (response.data.success == 1) {
                    this.data = response.data.data;
                } else {
                    this.$toast(response.data.message);
                }
            })
            .catch(error => {
                console.log(error);
                this.$toast("连接服务器异常");
            });
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.con {
    width: 100%;
    min-height: 100vh;
    background: #f9f9f9;
}
.nav {
    width: 100%;
    height: 44px;
    background: #fff;
}
.nav p {
    float: left;
    width: 49%;
    height: 44px;
    text-align: center;
    line-height: 44px;
}
.nav p:first-child {
    border-right: 1px solid #f2f2f2;
}
.title p {
    width: 33%;
    float: left;
    margin-top: 24px;
    color: #a6a9b5;
    text-align: center;
}
.title {
    height: 50px;
    width: 90%;
    margin-left: 5%;
}
.list {
    width: 100%;
    background: #fff;
}
.list ul {
    width: 90%;
    margin-left: 5%;
    border-bottom: 1px solid #f2f2f2;
    height: 60px;
}
.list:last-child ul {
    border: none;
}
.list ul li {
    height: 60px;
    line-height: 60px;
    float: left;
    width: 33.3%;
    text-align: center;
}

.active {
    color: #ffae4e;
}
</style>
